#ifndef DATASOURCEMGR_H
#define DATASOURCEMGR_H

#ifdef __Win32__
#pragma warning(disable:4786)
#endif

#include <map>
#include <string>

#include "OSHeaders.h"
#include "OSMutex.h"
#include "BusinessDNA.h"


class CDataSource;
class CBusinessDNA;
class CRTMediaSource;
class CDataSourceMgr
{
protected:
	CDataSourceMgr();
	~CDataSourceMgr();

public:
	static Int32	NewInstance();
	static CDataSourceMgr *	GetInstance();
	static void	DelInstance();

public:
	//pMovie URL
	CDataSource *	GetDataSource(CBusinessDNA &inBusinessDNA);
	Int32			FreeDataSource(CDataSource *pDataSource);
	//MovieName
	CDataSource *	FindDataSource(const char *pMovie);

	void InitEnumerator();
	void ReleaseEnumerator();
	CDataSource* EnumDataSource();
	Bool            AddDataSource( CDataSource* pDataSource );

protected:
	CDataSource *	AllocateDataSource(CBusinessDNA &inBusinessDNA);
	
protected:
	typedef std::map<std::string, CDataSource *>	_DataSourceMap;
	typedef _DataSourceMap::iterator			_DataSourceMapIterator;

protected:
	_DataSourceMap		m_mapDataSources;
	OSMutex				m_mtxDataSources;

private:
	_DataSourceMapIterator m_iterTrace;
	static CDataSourceMgr*		m_Instance;
};

#endif
